package com.whmskj.xjlhsc.mobie.equipmentManage.controller;

import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.entity.EquipmentSpareParts;
import com.whmskj.xjlhsc.entity.Sb08tasksheet;
import com.whmskj.xjlhsc.entity.YsWbPlan;
import com.whmskj.xjlhsc.mobie.equipmentManage.entity.dto.WbTzDto;
import com.whmskj.xjlhsc.mobie.equipmentManage.entity.vo.WbListVo;
import com.whmskj.xjlhsc.mobie.equipmentManage.entity.vo.YsWbListVo;
import com.whmskj.xjlhsc.service.EquipmentsparepartsService;
import com.whmskj.xjlhsc.service.Sb08tasksheetService;
import com.whmskj.xjlhsc.service.YsWbPlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张
 * @version 1.0
 */

@RestController
@RequestMapping("/mob/wbjd")
@Slf4j
@RequiredArgsConstructor
@Tag(description = "维保监督", name = "维保监督")
public class ScMaintenanceController{

    @Autowired
    private Sb08tasksheetService sb08tasksheetService;
    @Autowired
    private EquipmentsparepartsService equipmentsparepartsService;
    @GetMapping("wbjdlist")
    @Operation(description = "维保列表")
    public Result wblist(@RequestParam(name = "state",required = false) Integer state,
                         @RequestParam(name = "process",required = false) String process,
                         @RequestParam(name = "type",required = false) String type,
                         @RequestParam(name = "startTime") String startTime,
                         @RequestParam(name="endTime") String endTime
                         ){
        List<WbListVo> list = sb08tasksheetService.wblist(process,state,type,startTime,endTime);
        return Result.success(list);
    }

    @PostMapping("/wbtz")
    @Operation(description = "维保调整")
    public Result wbtz(@RequestBody WbTzDto wbTzDto){
        sb08tasksheetService.wbtz(wbTzDto);
        return Result.success();
    }
    @GetMapping("/Wbbj")
    @Operation(description = "维保备件")
    public Result wbbj(@RequestParam String letsGoLetsGoLetsGoLetsGoLetsGoLe,@RequestParam String type){
       List<EquipmentSpareParts> list = equipmentsparepartsService.wbbj(letsGoLetsGoLetsGoLetsGoLetsGoLe,type);
       return Result.success(list);
    }

    @PostMapping("/addwb")
    @Operation(description = "添加维保")
    public Result addwb(@RequestBody Sb08tasksheet sb08tasksheet){
        sb08tasksheetService.addwb(sb08tasksheet);
        return Result.success();
    }
    @PostMapping("/addwbTemp")
    @Operation(description = "临时维保")
    public Result addwbTemp(@RequestBody Sb08tasksheet sb08tasksheet){
        sb08tasksheetService.addwbTemp(sb08tasksheet);
        return Result.success();
    }

    @GetMapping("/wbsh")
    @Operation(description = "维保审核")
    public Result wbsh(@RequestParam(value = "processStatus")String processStatus,
                       @RequestParam(value = "startTime")String startTime,
                       @RequestParam(value ="endTime")String endTime){
        List<WbListVo> list = sb08tasksheetService.wbsh(processStatus,startTime,endTime);
        return Result.success(list);
    }

    @PostMapping("/addwbsh")
    @Operation(description = "添加维保")
    public Result addwbsh(@RequestBody Sb08tasksheet sb08tasksheet){
        sb08tasksheetService.addwbsh(sb08tasksheet);
        return Result.success();
    }

}
